/*
 * AircraftCarrier.cpp
 *
 *  Created on: Jun 21, 2009
 *      Author: computer
 */

#include "AircraftCarrier.h"

AircraftCarrier :: AircraftCarrier(const string& _name, const Point<int>& _origin, const AircraftCarrierConfiguration* config, char _fillChar)
: Boat(_name, _origin) {
	hull = config->getHullShape(_name, _origin, _fillChar);
	deck = config->getDeckShape(_name, _origin, _fillChar);
}

AircraftCarrier :: ~AircraftCarrier() {
	delete hull;
	delete deck;
}

bool AircraftCarrier :: fireToBoat(const Point<int>& pt, Arena* ar) {
	if (hull->fireToBoat(pt, ar) || deck->fireToBoat(pt, ar)) {
		if (isDestroyed()) {
			hull->writeDestroyed(ar);
			deck->writeDestroyed(ar);
		}
		return true;
	}
	return false;
}

bool AircraftCarrier :: isDestroyed() {
	return hull->isDestroyed() && deck->isDestroyed();
}

void AircraftCarrier :: write(Arena* ar) throw (OutOfBound, OverlapBoat, TooNearBoat) {
	hull->write(ar);
	deck->write(ar);
}
